package com.dingyuhang.util;

import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class MyInterceptor implements HandlerInterceptor{

	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		String contextPath = request.getContextPath();
		System.out.println(contextPath);

		HttpSession session = request.getSession();
		Object obj = session.getAttribute("LOGIN_USER");




		if(obj !=null) {
			return true;
		}
		response.sendRedirect(contextPath+"/login");
		return false;
	}
}
